﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Migrator.Util;
using Migrator.Entities;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

namespace Migrator.Packets
{
    /// <summary>
    /// UDP Packet
    /// 
    /// Header structure:
    ///  0                   1                 
    ///  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 
    /// +--------+--------+--------+--------+ 
    /// |   Source port   |   Dest. port    | 
    /// +--------+--------+--------+--------+ 
    /// |     Length      |    Checksum     | 
    /// +--------+--------+--------+--------+ 
    /// |          data octets ...            
    /// +---------------- ...                
    /// </summary>
    public class UDPPacket : IPPacket
    {
        public UDPPacket(Node source, IPAddress destinationIP, ushort sourcePort, ushort destinationPort)
            : base(source, destinationIP)
        {
            this.SourcePort = sourcePort;
            this.DestinationPort = destinationPort;
        }


        public override string ToString()
        {
            return this.GetType().Name + "[" + this.Source.IPAddress + ":" + this.SourcePort + " -> " + this.DestinationIP + ":" + this.DestinationPort + "]";
        }

        public ushort SourcePort
        {
            get;
            private set;
        }

        public ushort DestinationPort
        {
            get;
            private set;
        }
    }
}
